<%@ include file="/WEB-INF/jspf/directive/taglib.jspf"%>

<html>

<c:set var="title">
	<fmt:message key="account.title.text" />
</c:set>
<%@ include file="/WEB-INF/jspf/head.jspf"%>

<body>
	<div class="container">
		<h3>
			<fmt:message key="account.label.accountdata" />:
		</h3>
		<p class="lead">
			<fmt:message key="account.label.id" />:
			<c:out value="${account.id}"></c:out>
		</p>
		<p class="lead">
			<fmt:message key="account.label.balance" />:
			<c:out value="${account.balance}"></c:out>
			<c:out value="${account.valuta.shortName}"></c:out>
		</p>
		<c:if test="${account.accountState.ordinal == 0}">
			<a href="controller?command=browseRefillPage" class="btn btn-large">
				<fmt:message key="account.label.refill" />
			</a>
			<br>
			<br>
		</c:if>
		<p class="lead">
			<fmt:message key="account.label.status" />:
			<c:out value="${account.accountState}"></c:out>
		</p>
		<%-- Can do better with scriptlets, but.. --%>
		<c:if test="${account.accountState.ordinal == 0}">
			<form action="controller" name="blockAccountForm">
				<input name="command" type="hidden" value="blockAccount"> <input
					name="id" type="hidden" value=<c:out value="${account.id}"></c:out>>
				<a href="" class="btn btn-inverse btn-large"
					onclick="document.forms['blockAccountForm'].submit(); return false;">
					<fmt:message key="account.button.close" />
				</a>
			</form>
			<br />
		</c:if>

		<c:choose>

			<c:when test="${fn:length(cards) == 0}">
				<h3>
					<fmt:message key="account.label.nocreditcards" />
				</h3>
			</c:when>

			<c:otherwise>
				<h3>
					<fmt:message key="account.label.yourcreditcards" />
					:
				</h3>

				<c:forEach var="card" items="${sessionScope['cards']}">
					<form action="controller" name="cardForm${card.id}">
						<input name="command" type="hidden" value="deleteCard"> <input
							name="id" type="hidden" value="${card.id}">
						<p class="lead">
							<fmt:message key="account.label.card" />:
							<c:out value="${card.number}"></c:out>:<c:out value="${card.securityCode}"></c:out>
							: 
							<a href=""
								onclick="document.forms['cardForm${card.id}'].submit(); return false;">
								<fmt:message key="account.button.delete" />
							</a>
						</p>
					</form>
				</c:forEach>

			</c:otherwise>
		</c:choose>

		<%-- Can do better with scriptlets, but.. --%>
		<c:if test="${account.accountState == 'OPEN'}">
			<a href="controller?command=createCard"
				class="btn btn-large medium-button mrg-btn"> <fmt:message
					key="account.button.addcard" />
			</a>
			<br>
		</c:if>

		<a href="controller?command=browseAccounts"
			class="btn btn-large medium-button mrg-btn"> <fmt:message
				key="account.button.back" />
		</a> <br />
	</div>
</body>
</html>